package com.motong.gongdan.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * 设备信息
 */
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "设备信息")
@Data
@Accessors(chain = true)
@TableName(value = "device_info")
public class DeviceInfo extends PublicPo implements Serializable {
    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "id")
    private Long id;

    /**
     * 设备名称
     */
    @TableField(value = "device_name")
    @ApiModelProperty(value = "设备名称")
    private String deviceName;

    /**
     * 分组id
     */
    @TableField(value = "group_id")
    @ApiModelProperty(value = "分组ID(common_tree表id)")
    private Long groupId;

    /**
     * 当前任务id(mission表id)
     */
    @TableField(value = "mission_id")
    @ApiModelProperty(value = "当前任务id(mission表id)")
    private Integer missionId;

    /**
     * 绑定人员(user表id)
     */
    @TableField(value = "bind_user", updateStrategy = FieldStrategy.IGNORED)
    @ApiModelProperty(value = "绑定人员(user表id)")
    private Integer bindUser;

    /**
     * 设备管理员
     */
    @TableField(value = "device_admin", updateStrategy = FieldStrategy.IGNORED)
    @ApiModelProperty(value = "设备管理员(user表id)")
    private Integer deviceAdmin;

    /**
     * 设备管理员名称
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "设备管理员名称")
    private String deviceAdminName;

    /**
     * 设备图片
     */
    @TableField(value = "device_pic", updateStrategy = FieldStrategy.IGNORED)
    @ApiModelProperty(value = "设备图片")
    private String devicePic;

    /**
     * 设备编号
     */
    @TableField(value = "device_sn")
    @ApiModelProperty(value = "设备编号")
    private String deviceSn;

    /**
     * 设备序列号
     */
    @TableField(value = "real_device_sn")
    @ApiModelProperty(value = "设备序列号")
    private String realDeviceSn;

    /**
     * 状态(0 关机, 1 运行, 2 等待, 3 故障,4 离线)
     */
    @TableField(value = "`status`")
    @ApiModelProperty(value = "状态(0 关机, 1 运行, 2 等待, 3 故障,4 离线)")
    private Integer status;

    /**
     * 启用日期
     */
    @TableField(value = "enable_time")
    @ApiModelProperty(value = "启用日期")
    private Date enableTime;

    /**
     * 备注
     */
    @TableField(value = "remark")
    @ApiModelProperty(value = "备注")
    private String remark;

    @TableField(value = "csq")
    @ApiModelProperty(value = "信号强度")
    private String cSQ;

    /**
     * 创建人(user表id)
     */
    @TableField(value = "create_user")
    @ApiModelProperty(value = "创建人(user表id)", hidden = true)
    private Integer createUser;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    @ApiModelProperty(value = "创建时间", hidden = true)
    private Date createTime;

    /**
     * 更新人(user表id)
     */
    @TableField(value = "update_user")
    @ApiModelProperty(value = "更新人(user表id)", hidden = true)
    private Integer updateUser;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    @ApiModelProperty(value = "更新时间", hidden = true)
    private Date updateTime = new Date();

    public DeviceInfo setDeviceNameByObject(Object deviceName) {
        this.deviceName = Objects.isNull(deviceName) ? null : deviceName.toString();
        return this;

    }

    public DeviceInfo setDeviceSnByObject(Object deviceSn) {
        this.deviceSn = Objects.isNull(deviceSn) ? null : deviceSn.toString();
        return this;
    }

    public DeviceInfo setRemarkByObject(Object remark) {
        this.remark = Objects.isNull(remark) ? null : remark.toString();
        return this;
    }

    public DeviceInfo setDeviceAdminNameByObject(Object deviceAdminName) {
        this.deviceAdminName = Objects.isNull(deviceAdminName) ? null : deviceAdminName.toString();
        return this;
    }


    private static final long serialVersionUID = 1L;
}